package com.vcens.dingnotice.repository;

import com.vcens.dingnotice.entity.TaskEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TaskerMapper {

    @Insert("INSERT INTO task_infos(name,task_group,task_desc,cron_expression,task_state,create_time,update_time) VALUES(#{name},#{taskGroup},#{taskDesc},#{cronExpression},#{taskState},#{createTime},#{updateTime})")
    int insert(TaskEntity taskEntity);

    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "taskGroup", column = "task_group"),
            @Result(property = "taskDesc", column = "task_desc"),
            @Result(property = "cronExpression", column = "cron_expression"),
            @Result(property = "taskState", column = "task_state"),
            @Result(property = "createTime", column = "create_time"),
            @Result(property = "updateTime", column = "update_time")
    })
    @Select("SELECT * FROM task_infos WHERE id = #{taskId}")
    TaskEntity selectByTaskId(Integer taskId);

    @Insert("UPDATE task_infos SET task_state = 1 WHERE id = #{taskId}")
    void updateByTaskId(Integer taskId);
}
